<?
if (isset($_POST['btngo'])) {
    require("required/dbconnect.php");
    $main_cat = $_POST['main_cat'];
    $pageno = $_POST['pageno'];
    header("Location:uploadfiles.php?page=$pageno");
}

$title = "Content";
$pageid = "4";
$accessid = ",a10,";

if (isset($_POST['btnsubmit'])) {
    require("required/dbconnect.php");

    $content_chn = mysql_escape_string($_POST['content_chn']);
    $content_eng = mysql_escape_string($_POST['content_eng']);
    $url_chn = $_POST['url_chn'];
    $url_eng = $_POST['url_eng'];
    $create_date = $_POST['create_date'];
    $status = $_POST['status'];
    $insert = mysql_query("insert into os_news(content_chn,content_eng,url_chn,url_eng,create_date,status)value('$content_chn','$content_eng','$url_chn','$url_eng','$create_date','$status')") or die(mysql_error());
    header("Location:news.php");
}

require("required/dbconnect.php");
require("required/function.php");


if (!empty($_GET['action'])) {

    switch ($_GET['action']) {
        case 1:
            $msg = "<div class='dw_success'>Data inserted</div>";

            break;
        case 2:
            $msg = "<div class='dw_success'>Data Deleted</div>";

            break;
        case 3:
            $msg = "<div class='dw_success'>Data Updated</div>";
            break;
        default:
            $msg = "Invalid";
            break;
    }

    echo "<script>displayMsg('divMsg')</script>";
} else {
    $msg = "";
}


if (empty($_GET['type'])) {
    die("Illegal Action!!");
}



$type = $_GET['type'];



if (!empty($_GET['redirect'])) {
    $get_content = mysql_query("select id from os_contents where content_type='$type' order by order_id asc limit 1") or die(mysql_error());
    $id = mysql_result($get_content, 0, "id");
    header("Location:content_edit.php?id=$id");
} else {
    $get_content = mysql_query("select * from os_contents where content_type='$type' order by order_id asc ") or die(mysql_error());
}

require("required/header.php");
checkAccess("allow_content_management", 1);
?>
<script src="required/js/jquery-1.4.2.js"></script>
<script src="required/js/common_javascript.js"></script>

<table width="100%"  cellpadding="0" cellspacing="5" height="300">
    <tr>


        <td valign="top">
            <div class="title"><?= getTypeName($type) ?></div>

            <div id="divMsg"><?= $msg ?></div>
            <table width="100%" class="solidborder">
                <tr class="table_header">
                    <td width="2%">No</td><td width="24%">Title</td><Td width="5%">Publish</td><Td width="20%">Page URL</td><td width="4%">Action</td>
                </tr>
<? if (mysql_num_rows($get_content) == 0) { ?>
                    <tr valign="top">
                        <td align="center" colspan="7">
                            - No record found - 
                        </td>
                        
                    <?
                } else {
                    $no = 1;
                    while ($a = mysql_fetch_array($get_content, MYSQL_ASSOC)) {
                        $id = $a['id'];
                        if ($no % 2 == 0) {
                            $class1 = "table_item_even";
                            $class2 = "table_item_odd";
                        } else {
                            $class1 = "table_item_odd";
                            $class2 = "table_item_even";
                        }
                        ?>
                        <tr height="20" valign="top" class="<?= $class1 ?>" onmouseover="this.className='table_item_mouseover'" 
                            onmouseout="this.className='<?= $class1 ?>'">
                            <td align="center"><?= $no ?></td>
                            <td><?= $a['title'] ?></td>
                            <td><?= $a['status']==0?"No":"Yes" ?></td>
                            <Td>os_content.php?type=<?= $type ?>&id=<?= $a['id'] ?></td>
                            <td align="center"><a href="content_edit.php?id=<?= $id ?>"><img src="images/icons/edit.gif" border="0"></a>  <a href="content_delete.php?type=<?= $type ?>&id=<?= $id ?>"><img src="images/icons/delete.gif" border="0"></a></td>								
                        </tr>
                            <?
                            $no++;
                        }
                    }
                    ?>

            </table>
            <br />
            <input type="button" value="Add" class="button" onclick="window.open('content_add.php?type=<?= $type ?>','_self')" />
        </td>
    </tr>


</table>
                <? require("required/footer.php"); ?>

